﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefMaterialBindRecord" :model="stateMaterialBindRecord.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineCode_FormItem" prop="LinkedVM.LineCode" :label="$t('message.autotrans._Model_MaterialBindRecord_lineCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_lineCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.LineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_StationCode_FormItem" prop="LinkedVM.StationCode" :label="$t('message.autotrans._Model_MaterialBindRecord_stationCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_stationCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.StationCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OrderCode_FormItem" prop="LinkedVM.OrderCode" :label="$t('message.autotrans._Model_MaterialBindRecord_orderCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_orderCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.OrderCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleCode_FormItem" prop="LinkedVM.ScheduleCode" :label="$t('message.autotrans._Model_MaterialBindRecord_scheduleCode')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.ScheduleCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_SnNumber_FormItem" prop="LinkedVM.SnNumber" :label="$t('message.autotrans._Model_MaterialBindRecord_snNumber')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.SnNumber" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialCode_FormItem" prop="LinkedVM.AssemblyMaterialCode" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialCode')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyMaterialCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialQty_FormItem" prop="LinkedVM.AssemblyMaterialQty" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialQty')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyMaterialQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblySort_FormItem" prop="LinkedVM.AssemblySort" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblySort')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblySort" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyTime_FormItem" prop="LinkedVM.AssemblyTime" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyTime')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialName_FormItem" prop="LinkedVM.AssemblyMaterialName" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialName')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyMaterialName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialVersion_FormItem" prop="LinkedVM.AssemblyMaterialVersion" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialVersion')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyMaterialVersion" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialSn_FormItem" prop="LinkedVM.AssemblyMaterialSn" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialSn')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.AssemblyMaterialSn" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialBatchNo_FormItem" prop="LinkedVM.MaterialBatchNo" :label="$t('message.autotrans._Model_MaterialBindRecord_materialBatchNo')">
          <el-input v-model="stateMaterialBindRecord.vmModel.LinkedVM.MaterialBatchNo" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Uploadflag_FormItem" prop="LinkedVM.Uploadflag" :label="$t('message.autotrans._Model_MaterialBindRecord_uploadflag')">
          <el-select v-model="stateMaterialBindRecord.vmModel.LinkedVM.Uploadflag" clearable>
             <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
             <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitMaterialBindRecord"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseMaterialBindRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageRecordMaterialBindRecordBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { materialbindrecordApi } from '/@/api/record/materialbindrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefMaterialBindRecord = ref();
const stateMaterialBindRecord = reactive({
    vmModel: {
	  LinkedVM:{
        LineCode: '',
        StationCode: '',
        OrderCode: '',
        ScheduleCode: '',
        SnNumber: '',
        AssemblyMaterialCode: '',
        AssemblyMaterialQty: '',
        AssemblySort: '',
        AssemblyTime: '',
        AssemblyMaterialName: '',
        AssemblyMaterialVersion: '',
        AssemblyMaterialSn: '',
        MaterialBatchNo: '',
        Uploadflag: undefined,
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseMaterialBindRecord = () => {
    closeDialog();
};

// 提交
const onSubmitMaterialBindRecord = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefMaterialBindRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            materialbindrecordApi().batchedit(stateMaterialBindRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateMaterialBindRecord.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateMaterialBindRecord.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

